/*
 * This file is a part of qloudgen-esb. 
 * You can redistribute qloudgen-esb and/or modify it under the terms of the Lesser GNU General Public License version 3. 
 * qloudgen-esb is distributed WITHOUT ANY WARRANTY. 
 * 
 * See the Lesser GNU General Public License for more details at http://www.gnu.org/licenses/.
 *  
 * Copyright (C) 2014 Qloudgen Technology
*/

package com.qloudgen.csb.client;

import java.util.ArrayList;
import java.util.List;

public class Session { 
	private List<Producer> producers = new ArrayList<Producer>();
	private List<Consumer> consumers = new ArrayList<Consumer>();
	
	protected Session() {
	}
	
	protected void run() {
		for (int i = 0; i < consumers.size(); i++) {
			new Thread(consumers.get(i)).start();
		}
	}
	
	public void close() {		
	}

	public Producer createProducer(Queue queue, int timeout, int retry) {		
		Producer producer = 
				new Producer(queue.getConn(), timeout, retry);
		producers.add(producer);
		return producer;
	}

	public Consumer createConsumer(Queue queue) {
		Consumer consumer = new Consumer(queue.getConn());
		consumers.add(consumer);
		return consumer;
	}
	
	public Queue createQueue(String queueName) {
		//find out addr:port for queue
		String conn = "";
		
		return createQueue(queueName, conn);
	}

	public Queue createQueue(String queueName, String conn) {
		return new Queue(queueName, conn);
	}

	public Message createMessage() {
		return new Message("");
	}

}

